package com.oz.entity;

import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OrderColumn;
import javax.persistence.Transient;

import org.hibernate.annotations.Comment;
import org.hibernate.annotations.Table;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

@Table(appliesTo = "basic_role", comment = "用户权限")
@Entity(name = "basic_role")
@TableName(value = "basic_role")
public class RoleEntity {

	@Id
	@Column(length = 32)
	private String id;

	@Comment("权限名称") // 权限名称
	@Column(length = 16)
	private String role;

	@Comment("权限备注")
	@Column(length = 64, unique = true)
	private String remark;

	@Transient
	@TableField(exist = false)
	@Comment("该权限所有用户")
	@ManyToMany	
	@JoinTable(name = "user_role", joinColumns = { @JoinColumn(name = "role_id", referencedColumnName = "id") }, inverseJoinColumns = {
			@JoinColumn(name = "user_id", referencedColumnName = "id"), })
	@OrderColumn(name = "start_date",columnDefinition = "TIMESTAMP DEFAULT CURRENT_TIMESTAMP" ) //中间表加入一个时间
	List<UserEntity> users;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getRole() {
		return role;
	}

	public void setRole(String role) {
		this.role = role;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public List<UserEntity> getUsers() {
		return users;
	}

	public void setUsers(List<UserEntity> users) {
		this.users = users;
	}

	
}
